Function.prototype.myApply = function(context) {
    context = context || window
    context.fn = this
    let args = [], result
    if(arguments.length == 1) {
        result = context.fn()
    } else {
        args = [...arguments[1]]
        result = context.fn(...args)
    }
    // context本身没有fn，所以去掉
    delete context.fn
    return result
}
function add(num1, num2) {
    console.log(this.name);
    return num1 + num2
}
let obj = {
    name: 'zzy'
}
console.log(add.myApply(obj, [1, 2]))